package com.msmall.community.question.service;

import com.msmall.base.pager.PaginationSupport;
import com.msmall.base.service.BaseManager;
import com.msmall.base.util.ConstantDB;
import com.msmall.community.question.model.Answer;
import com.msmall.community.question.model.Question;

public interface QuestionManager extends BaseManager<Question, Long>{

	public Question saveQuestion(Question q, Long userid, String uat) throws Exception;
	
	/**
	 * 同时增加问题回答数量
	 */
	public Answer saveQuestionAnswer(Answer q, Long userid, String uat) throws Exception;
	
	/**
	 * 增加查看问题次数
	 */
	public Question incrementQuestionClickAmount(Long questionid) throws Exception;
	
	/**
	 * 获得提问的回复.enabed or not都选出
	 * @param page
	 * @param userid 当前登录系统的用户，用于分页的PAGESIZE
	 */
	public void getAnswerPaginationByQuestion(PaginationSupport page, Long userid, Long questionid) throws Exception;
	
	/**
	 * 获得提问列表 enabled
	 * ConstantDB.QUESTION_TERMINAL_NO
	 */
	public void getQuestionPagination(PaginationSupport page, Long segmentid, int terminal) throws Exception;
	
	/**
	 * 通过用户ID 获得此用户发表的提问
	 */
	public void getQuestionPaginationByUserid(PaginationSupport page, Long userid) throws Exception;
	
	/**
	 * 通过用户ID 获得此用户对提问的回答
	 */
	public void getAnswerPaginationByUserid(PaginationSupport page, Long userid) throws Exception;
	/**
	 * 获得segment下点击数最多的问题 enabled
	 * containsChildren 是否统计segid
	 */
	public void getPaginationByClickAmount(PaginationSupport page, Long segid, boolean containsChildren) throws Exception;
	
	/**
	 * 根据顶层问题分类包括相应的子分类，查询出点击数最高的amount个问题。pagination不统计总数
	 * 由JOB每1小时执行一次
	 */
	public void refreshQuestionByClickAmount(int amount);
	/**
	 * 验证Question.Answer content
	 * @return 1:正常；2字符太少；3字符太多;4含有非法字符
	 */
	public int validateAnswerContent(String content);
	
	/**
	 * 验证Question content
	 * @return 1:正常；2字符太少；3字符太多;4含有非法字符
	 */
	public int validateQuestionContent(String content);
	/**
	 * 用户是否被授权推荐问答
	 */
	public boolean isAuthorizedCommend(Long userid);
	/**
	 * 用户是否被授权删除问答/回复
	 */
	public boolean isAuthorizedRemove(Long userid);
	
	/**
	 * 删除问答
	 */
	public Question delQuestion(Long userid, Long questionid) throws Exception ;
	/**
	 * 删除问答回复
	 */
	public Answer delAnswer(Long userid, Long answerid) throws Exception ;
}
